package com.zhida.userservice.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author ling
 * @since 2024-07-20
 */
@Getter
@Setter
@TableName("user")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户编码
     */
    @TableId(value = "user_id", type = IdType.AUTO)
    private Integer userId;

    /**
     * 用户名
     */
    @TableField("username")
    private String username;

    /**
     * 密码 已加密
     */
    @TableField("password")
    private String password;

    /**
     * 登录状态 -> 0：未登录，1：已登录
     */
    @TableField("login_status")
    private Integer loginStatus;

    /**
     * 0：普通，1：vip
     */
    @TableField("vip_status")
    private Integer vipStatus;

    /**
     * 注册时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat( pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat( pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("update_time")
    private LocalDateTime updateTime;

    /**
     * base64
     */
    @TableField("header")
    private String header;

    /**
     * 财商
     */
    @TableField("financial")
    private Integer financial;

    /**
     * 情商
     */
    @TableField("emotional")
    private Integer emotional;

    /**
     * 技能
     */
    @TableField("skill")
    private Integer skill;

    /**
     * 昵称
     */
    @TableField("nickname")
    private String nickname;

    /**
     * 邮箱
     */
    @TableField("email")
    private String email;

    /**
     * 联系方式
     */
    @TableField("phone")
    private String phone;

    /**
     * 消息数量
     */
    @TableField("msg_count")
    private Integer msgCount;

    public User(String username, String password) {
        this.username = username;
        this.password = password;
        this.phone = username;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", loginStatus=" + loginStatus +
                ", vipStatus=" + vipStatus +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", header='" + header + '\'' +
                ", financial=" + financial +
                ", emotional=" + emotional +
                ", skill=" + skill +
                ", nickname='" + nickname + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", msgCount=" + msgCount +
                '}';
    }
}
